// src/scenarios/smart_campus.rs

//! 智慧园区场景
//! 支持智慧园区的语义转换和OPC UA模型构建

use crate::scenarios::*;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

/// 智慧园区场景
pub struct SmartCampusScenario {
    config: ScenarioConfig,
}

impl SmartCampusScenario {
    pub fn new() -> Self {
        Self {
            config: ScenarioConfig {
                name: Some("智慧园区语义转换场景".to_string()),
                description: Some("支持智慧园区数据的语义转换和OPC UA模型构建，包括安防监控、能耗管理、环境监测等".to_string()),
                custom_rules: None,
                extensions: HashMap::new(),
            },
        }
    }

    pub fn new_with_config(config: ScenarioConfig) -> Self {
        Self { config }
    }
}

impl Scenario for SmartCampusScenario {
    fn name(&self) -> &'static str {
        "Smart Campus Semantic Conversion"
    }

    fn description(&self) -> &'static str {
        "智慧园区语义转换场景，支持园区管理数据的语义转换"
    }

    fn industry(&self) -> &'static str {
        "SmartCampus"
    }

    fn get_transformation_rules(&self) -> ScenarioTransformationRules {
        ScenarioTransformationRules {
            rule_name: "Smart_Campus_General".to_string(),
            data_source_mappings: HashMap::new(),
            unit_conversions: HashMap::new(),
            data_type_mappings: HashMap::new(),
            semantic_mappings: HashMap::new(),
            constraints: vec![],
        }
    }

    fn get_opcua_model_template(&self) -> ScenarioModelTemplate {
        ScenarioModelTemplate {
            template_name: "SmartCampusModel".to_string(),
            namespaces: vec![
                "http://opcfoundation.org/UA/".to_string(),
                "http://industryagent.com/smartcampus/".to_string(),
            ],
            object_types: vec![],
            variable_types: vec![],
            reference_types: vec![],
        }
    }

    fn get_sample_data(&self) -> Vec<ScenarioSampleData> {
        vec![
            ScenarioSampleData {
                data_id: "campus_sensor_001".to_string(),
                data_source_type: "HuaweiCloudIoT".to_string(),
                raw_data: serde_json::json!({
                    "sensor_id": "ENV-001",
                    "location": "教学楼A座",
                    "temperature": 22.5,
                    "humidity": 55.0,
                    "air_quality": "Good",
                    "timestamp": "2024-01-15T10:30:00Z"
                }),
                expected_opcua: serde_json::json!({"nodeId": "ns=6;i=1001"}),
                description: Some("园区环境传感器数据示例".to_string()),
                category: Some("EnvironmentalMonitoring".to_string()),
            },
        ]
    }

    fn get_semantic_mappings(&self) -> HashMap<String, String> {
        let mut mappings = HashMap::new();
        mappings.insert("temperature_sensor".to_string(), "TemperatureSensor".to_string());
        mappings
    }
}